<?php
define("EW_PAGE_ID", "add", TRUE); // Page ID
define("EW_TABLE_NAME", 'orders_movie', TRUE);
?>
<?php 
session_start(); // Initialize session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg50.php" ?>
<?php include "ewmysql50.php" ?>
<?php include "phpfn50.php" ?>
<?php include "orders_movieinfo.php" ?>
<?php include "userfn50.php" ?>
<?php include "usersinfo.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Open connection to the database
$conn = ew_Connect();
?>
<?php
$Security = new cAdvancedSecurity();
?>
<?php
if (!$Security->IsLoggedIn()) $Security->AutoLogin();
$Security->LoadCurrentUserLevel('orders_movie');
if (!$Security->IsLoggedIn()) {
	$Security->SaveLastUrl();
	Page_Terminate("login.php");
}
if (!$Security->CanAdd()) {
	$Security->SaveLastUrl();
	Page_Terminate("orders_movielist.php");
}
?>
<?php

// Common page loading event (in userfn*.php)
Page_Loading();
?>
<?php

// Page load event, used in current page
Page_Load();
?>
<?php
$orders_movie->Export = @$_GET["export"]; // Get export parameter
$sExport = $orders_movie->Export; // Get export parameter, used in header
$sExportFile = $orders_movie->TableVar; // Get export file, used in header
?>
<?php

// Load key values from QueryString
$bCopy = TRUE;
if (@$_GET["id"] != "") {
  $orders_movie->id->setQueryStringValue($_GET["id"]);
} else {
  $bCopy = FALSE;
}

// Create form object
$objForm = new cFormObj();

// Process form if post back
if (@$_POST["a_add"] <> "") {
  $orders_movie->CurrentAction = $_POST["a_add"]; // Get form action
  LoadFormValues(); // Load form values
} else { // Not post back
  if ($bCopy) {
    $orders_movie->CurrentAction = "C"; // Copy Record
  } else {
    $orders_movie->CurrentAction = "I"; // Display Blank Record
    LoadDefaultValues(); // Load default values
  }
}

// Perform action based on action code
switch ($orders_movie->CurrentAction) {
  case "I": // Blank record, no action required
		break;
  case "C": // Copy an existing record
   if (!LoadRow()) { // Load record based on key
      $_SESSION[EW_SESSION_MESSAGE] = "No records found"; // No record found
      Page_Terminate($orders_movie->getReturnUrl()); // Clean up and return
    }
		break;
  case "A": // ' Add new record
		$orders_movie->SendEmail = TRUE; // Send email on add success
    if (AddRow()) { // Add successful
      $_SESSION[EW_SESSION_MESSAGE] = "Add New Record Successful"; // Set up success message
      Page_Terminate($orders_movie->KeyUrl($orders_movie->getReturnUrl())); // Clean up and return
    } else {
      RestoreFormValues(); // Add failed, restore form values
    }
}

// Render row based on row type
$orders_movie->RowType = EW_ROWTYPE_ADD;  // Render add type
RenderRow();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--
var EW_PAGE_ID = "add"; // Page id
var EW_SHOW_HIGHLIGHT = "Show highlight"; 
var EW_HIDE_HIGHLIGHT = "Hide highlight";

//-->
</script>
<script type="text/javascript">
<!--

function ew_ValidateForm(fobj) {
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_bill"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Bill"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_pro_id"];
		if (elm && !ew_CheckInteger(elm.value)) {
			if (!ew_OnError(elm, "Incorrect integer - Pro ID"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_pro_quantity"];
		if (elm && !ew_CheckInteger(elm.value)) {
			if (!ew_OnError(elm, "Incorrect integer - Quantity"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_pro_totalmoney"];
		if (elm && !ew_CheckNumber(elm.value)) {
			if (!ew_OnError(elm, "Incorrect floating point number - Totalmoney"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_dateadd"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Date Add"))
				return false;
		}
		elm = fobj.elements["x" + infix + "_dateadd"];
		if (elm && !ew_CheckEuroDate(elm.value)) {
			if (!ew_OnError(elm, "Incorrect date, format = dd/mm/yyyy - Date Add"))
				return false; 
		}
		elm = fobj.elements["x" + infix + "_status[]"];
		if (elm && !ew_HasValue(elm)) {
			if (!ew_OnError(elm, "Please enter required field - Status"))
				return false;
		}
	}
	return true;
}

//-->
</script>
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
<script type="text/javascript">
<!--
_width_multiplier = 16;
_height_multiplier = 60;
var ew_DHTMLEditors = [];

function ew_UpdateTextArea() {
	if (typeof ew_DHTMLEditors != 'undefined' &&
		typeof FCKeditorAPI != 'undefined') {			
			var inst;			
			for (inst in FCKeditorAPI.__Instances)
				FCKeditorAPI.__Instances[inst].UpdateLinkedField();
	}
}

//-->
</script>
<link rel="stylesheet" type="text/css" media="all" href="calendar/calendar-win2k-1.css" title="win2k-1" />
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></script>
<script type="text/javascript">
<!--
var ew_MultiPagePage = "Page"; // multi-page Page Text
var ew_MultiPageOf = "of"; // multi-page Of Text
var ew_MultiPagePrev = "Prev"; // multi-page Prev Text
var ew_MultiPageNext = "Next"; // multi-page Next Text

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<p><span class="phpmaker">Add to TABLE: orders movie<br><br><a href="<?php echo $orders_movie->getReturnUrl() ?>">Go Back</a></span></p>
<?php
if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Mesasge in Session, display
?>
<p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
<?php
  $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
}
?>
<form name="forders_movieadd" id="forders_movieadd" action="orders_movieadd.php" method="post">
<p>
<input type="hidden" name="a_add" id="a_add" value="A">
<table class="ewTable">
  <tr class="ewTableRow">
    <td class="ewTableHeader">Bill<span class='ewmsg'>&nbsp;*</span></td>
    <td<?php echo $orders_movie->bill->CellAttributes() ?>><span id="cb_x_bill">
<input type="text" name="x_bill" id="x_bill"  size="30" maxlength="250" value="<?php echo $orders_movie->bill->EditValue ?>"<?php echo $orders_movie->bill->EditAttributes() ?>>
</span></td>
  </tr>
  <tr class="ewTableAltRow">
    <td class="ewTableHeader">Fullname</td>
    <td<?php echo $orders_movie->fullname->CellAttributes() ?>><span id="cb_x_fullname">
<input type="text" name="x_fullname" id="x_fullname"  size="30" maxlength="250" value="<?php echo $orders_movie->fullname->EditValue ?>"<?php echo $orders_movie->fullname->EditAttributes() ?>>
</span></td>
  </tr>
  <tr class="ewTableRow">
    <td class="ewTableHeader">Email</td>
    <td<?php echo $orders_movie->email->CellAttributes() ?>><span id="cb_x_email">
<input type="text" name="x_email" id="x_email"  size="30" maxlength="250" value="<?php echo $orders_movie->email->EditValue ?>"<?php echo $orders_movie->email->EditAttributes() ?>>
</span></td>
  </tr>
  <tr class="ewTableAltRow">
    <td class="ewTableHeader">Address</td>
    <td<?php echo $orders_movie->address->CellAttributes() ?>><span id="cb_x_address">
<input type="text" name="x_address" id="x_address"  size="30" maxlength="250" value="<?php echo $orders_movie->address->EditValue ?>"<?php echo $orders_movie->address->EditAttributes() ?>>
</span></td>
  </tr>
  <tr class="ewTableRow">
    <td class="ewTableHeader">Telephone</td>
    <td<?php echo $orders_movie->tel->CellAttributes() ?>><span id="cb_x_tel">
<input type="text" name="x_tel" id="x_tel"  size="30" maxlength="15" value="<?php echo $orders_movie->tel->EditValue ?>"<?php echo $orders_movie->tel->EditAttributes() ?>>
</span></td>
  </tr>
  <tr class="ewTableAltRow">
    <td class="ewTableHeader">Note</td>
    <td<?php echo $orders_movie->note->CellAttributes() ?>><span id="cb_x_note">
<textarea name="x_note" id="x_note" cols="35" rows="4"<?php echo $orders_movie->note->EditAttributes() ?>><?php echo $orders_movie->note->EditValue ?></textarea>
<script type="text/javascript">
<!--
var editor = new ew_DHTMLEditor("x_note");
editor.create = function() {
	var sBasePath = 'fckeditor/';
	var oFCKeditor = new FCKeditor('x_note', 35*_width_multiplier, 4*_height_multiplier);
	oFCKeditor.BasePath = sBasePath;
	oFCKeditor.ReplaceTextarea();
	this.active = true;
}
ew_DHTMLEditors[ew_DHTMLEditors.length] = editor;
-->
</script>
</span></td>
  </tr>
  <tr class="ewTableRow">
    <td class="ewTableHeader">Pro ID</td>
    <td<?php echo $orders_movie->pro_id->CellAttributes() ?>><span id="cb_x_pro_id">
<input type="text" name="x_pro_id" id="x_pro_id"  size="30" value="<?php echo $orders_movie->pro_id->EditValue ?>"<?php echo $orders_movie->pro_id->EditAttributes() ?>>
</span></td>
  </tr>
  <tr class="ewTableAltRow">
    <td class="ewTableHeader">Title</td>
    <td<?php echo $orders_movie->pro_title->CellAttributes() ?>><span id="cb_x_pro_title">
<input type="text" name="x_pro_title" id="x_pro_title"  size="30" maxlength="250" value="<?php echo $orders_movie->pro_title->EditValue ?>"<?php echo $orders_movie->pro_title->EditAttributes() ?>>
</span></td>
  </tr>
  <tr class="ewTableRow">
    <td class="ewTableHeader">Quantity</td>
    <td<?php echo $orders_movie->pro_quantity->CellAttributes() ?>><span id="cb_x_pro_quantity">
<input type="text" name="x_pro_quantity" id="x_pro_quantity"  size="30" value="<?php echo $orders_movie->pro_quantity->EditValue ?>"<?php echo $orders_movie->pro_quantity->EditAttributes() ?>>
</span></td>
  </tr>
  <tr class="ewTableAltRow">
    <td class="ewTableHeader">Totalmoney</td>
    <td<?php echo $orders_movie->pro_totalmoney->CellAttributes() ?>><span id="cb_x_pro_totalmoney">
<input type="text" name="x_pro_totalmoney" id="x_pro_totalmoney"  size="30" value="<?php echo $orders_movie->pro_totalmoney->EditValue ?>"<?php echo $orders_movie->pro_totalmoney->EditAttributes() ?>>
</span></td>
  </tr>
  <tr class="ewTableRow">
    <td class="ewTableHeader">Date Add<span class='ewmsg'>&nbsp;*</span></td>
    <td<?php echo $orders_movie->dateadd->CellAttributes() ?>><span id="cb_x_dateadd">
<input type="text" name="x_dateadd" id="x_dateadd"  value="<?php echo $orders_movie->dateadd->EditValue ?>"<?php echo $orders_movie->dateadd->EditAttributes() ?>>
&nbsp;<img src="images/ew_calendar.gif" id="cx_dateadd" alt="Pick a Date" style="cursor:pointer;cursor:hand;">
<script type="text/javascript">
Calendar.setup(
{
inputField : "x_dateadd", // ID of the input field
ifFormat : "%d/%m/%Y", // the date format
button : "cx_dateadd" // ID of the button
}
);
</script>
</span></td>
  </tr>
  <tr class="ewTableAltRow">
    <td class="ewTableHeader">Status<span class='ewmsg'>&nbsp;*</span></td>
    <td<?php echo $orders_movie->status->CellAttributes() ?>><span id="cb_x_status">
<?php
$arwrk = $orders_movie->status->EditValue;
if (is_array($arwrk)) {
	$armultiwrk= explode(",", strval($orders_movie->status->CurrentValue));
	$rowswrk = count($arwrk);
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = "";
		for ($ari = 0; $ari < count($armultiwrk); $ari++) {
			if (strval($arwrk[$rowcntwrk][0]) == trim(strval($armultiwrk[$ari]))) {
				$selwrk = " checked";
				break;
			}
		}
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<input type="checkbox" name="x_status[]" id="x_status[]" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $orders_movie->status->EditAttributes() ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</span></td>
  </tr>
</table>
<p>
<input type="button" name="btnAction" id="btnAction" value="    Add    " onClick="ew_SubmitForm(this.form);">
</form>
<script type="text/javascript">
<!--
ew_CreateEditor();  // Create DHTML editor(s)

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php include "footer.php" ?>
<?php

// If control is passed here, simply terminate the page without redirect
Page_Terminate();

// -----------------------------------------------------------------
//  Subroutine Page_Terminate
//  - called when exit page
//  - clean up connection and objects
//  - if url specified, redirect to url, otherwise end response
function Page_Terminate($url = "") {
	global $conn;

	// Page unload event, used in current page
	Page_Unload();

	// Global page unloaded event (in userfn*.php)
	Page_Unloaded();

	 // Close Connection
	$conn->Close();

	// Go to url if specified
	if ($url <> "") {
		ob_end_clean();
		header("Location: $url");
	}
	exit();
}
?>
<?php

// Load default values
function LoadDefaultValues() {
	global $orders_movie;
}
?>
<?php

// Load form values
function LoadFormValues() {

	// Load from form
	global $objForm, $orders_movie;
	$orders_movie->bill->setFormValue($objForm->GetValue("x_bill"));
	$orders_movie->fullname->setFormValue($objForm->GetValue("x_fullname"));
	$orders_movie->email->setFormValue($objForm->GetValue("x_email"));
	$orders_movie->address->setFormValue($objForm->GetValue("x_address"));
	$orders_movie->tel->setFormValue($objForm->GetValue("x_tel"));
	$orders_movie->note->setFormValue($objForm->GetValue("x_note"));
	$orders_movie->pro_id->setFormValue($objForm->GetValue("x_pro_id"));
	$orders_movie->pro_title->setFormValue($objForm->GetValue("x_pro_title"));
	$orders_movie->pro_quantity->setFormValue($objForm->GetValue("x_pro_quantity"));
	$orders_movie->pro_totalmoney->setFormValue($objForm->GetValue("x_pro_totalmoney"));
	$orders_movie->dateadd->setFormValue($objForm->GetValue("x_dateadd"));
	$orders_movie->dateadd->CurrentValue = ew_UnFormatDateTime($orders_movie->dateadd->CurrentValue, 7);
	$orders_movie->status->setFormValue($objForm->GetValue("x_status"));
}

// Restore form values
function RestoreFormValues() {
	global $orders_movie;
	$orders_movie->bill->CurrentValue = $orders_movie->bill->FormValue;
	$orders_movie->fullname->CurrentValue = $orders_movie->fullname->FormValue;
	$orders_movie->email->CurrentValue = $orders_movie->email->FormValue;
	$orders_movie->address->CurrentValue = $orders_movie->address->FormValue;
	$orders_movie->tel->CurrentValue = $orders_movie->tel->FormValue;
	$orders_movie->note->CurrentValue = $orders_movie->note->FormValue;
	$orders_movie->pro_id->CurrentValue = $orders_movie->pro_id->FormValue;
	$orders_movie->pro_title->CurrentValue = $orders_movie->pro_title->FormValue;
	$orders_movie->pro_quantity->CurrentValue = $orders_movie->pro_quantity->FormValue;
	$orders_movie->pro_totalmoney->CurrentValue = $orders_movie->pro_totalmoney->FormValue;
	$orders_movie->dateadd->CurrentValue = $orders_movie->dateadd->FormValue;
	$orders_movie->dateadd->CurrentValue = ew_UnFormatDateTime($orders_movie->dateadd->CurrentValue, 7);
	$orders_movie->status->CurrentValue = $orders_movie->status->FormValue;
}
?>
<?php

// Load row based on key values
function LoadRow() {
	global $conn, $Security, $orders_movie;
	$sFilter = $orders_movie->SqlKeyFilter();
	if (!is_numeric($orders_movie->id->CurrentValue)) {
		return FALSE; // Invalid key, exit
	}
	$sFilter = str_replace("@id@", ew_AdjustSql($orders_movie->id->CurrentValue), $sFilter); // Replace key value

	// Call Row Selecting event
	$orders_movie->Row_Selecting($sFilter);

	// Load sql based on filter
	$orders_movie->CurrentFilter = $sFilter;
	$sSql = $orders_movie->SQL();
	if ($rs = $conn->Execute($sSql)) {
		if ($rs->EOF) {
			$LoadRow = FALSE;
		} else {
			$LoadRow = TRUE;
			$rs->MoveFirst();
			LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$orders_movie->Row_Selected($rs);
		}
		$rs->Close();
	} else {
		$LoadRow = FALSE;
	}
	return $LoadRow;
}

// Load row values from recordset
function LoadRowValues(&$rs) {
	global $orders_movie;
	$orders_movie->id->setDbValue($rs->fields('id'));
	$orders_movie->bill->setDbValue($rs->fields('bill'));
	$orders_movie->fullname->setDbValue($rs->fields('fullname'));
	$orders_movie->email->setDbValue($rs->fields('email'));
	$orders_movie->address->setDbValue($rs->fields('address'));
	$orders_movie->tel->setDbValue($rs->fields('tel'));
	$orders_movie->note->setDbValue($rs->fields('note'));
	$orders_movie->pro_id->setDbValue($rs->fields('pro_id'));
	$orders_movie->pro_title->setDbValue($rs->fields('pro_title'));
	$orders_movie->pro_quantity->setDbValue($rs->fields('pro_quantity'));
	$orders_movie->pro_totalmoney->setDbValue($rs->fields('pro_totalmoney'));
	$orders_movie->dateadd->setDbValue($rs->fields('dateadd'));
	$orders_movie->status->setDbValue($rs->fields('status'));
}
?>
<?php

// Render row values based on field settings
function RenderRow() {
	global $conn, $Security, $orders_movie;

	// Call Row Rendering event
	$orders_movie->Row_Rendering();

	// Common render codes for all row types
	// bill

	$orders_movie->bill->CellCssStyle = "";
	$orders_movie->bill->CellCssClass = "";

	// fullname
	$orders_movie->fullname->CellCssStyle = "";
	$orders_movie->fullname->CellCssClass = "";

	// email
	$orders_movie->email->CellCssStyle = "";
	$orders_movie->email->CellCssClass = "";

	// address
	$orders_movie->address->CellCssStyle = "";
	$orders_movie->address->CellCssClass = "";

	// tel
	$orders_movie->tel->CellCssStyle = "";
	$orders_movie->tel->CellCssClass = "";

	// note
	$orders_movie->note->CellCssStyle = "";
	$orders_movie->note->CellCssClass = "";

	// pro_id
	$orders_movie->pro_id->CellCssStyle = "";
	$orders_movie->pro_id->CellCssClass = "";

	// pro_title
	$orders_movie->pro_title->CellCssStyle = "";
	$orders_movie->pro_title->CellCssClass = "";

	// pro_quantity
	$orders_movie->pro_quantity->CellCssStyle = "";
	$orders_movie->pro_quantity->CellCssClass = "";

	// pro_totalmoney
	$orders_movie->pro_totalmoney->CellCssStyle = "";
	$orders_movie->pro_totalmoney->CellCssClass = "";

	// dateadd
	$orders_movie->dateadd->CellCssStyle = "";
	$orders_movie->dateadd->CellCssClass = "";

	// status
	$orders_movie->status->CellCssStyle = "";
	$orders_movie->status->CellCssClass = "";
	if ($orders_movie->RowType == EW_ROWTYPE_VIEW) { // View row
	} elseif ($orders_movie->RowType == EW_ROWTYPE_ADD) { // Add row

		// bill
		$orders_movie->bill->EditCustomAttributes = "";
		$orders_movie->bill->EditValue = ew_HtmlEncode($orders_movie->bill->CurrentValue);

		// fullname
		$orders_movie->fullname->EditCustomAttributes = "";
		$orders_movie->fullname->EditValue = ew_HtmlEncode($orders_movie->fullname->CurrentValue);

		// email
		$orders_movie->email->EditCustomAttributes = "";
		$orders_movie->email->EditValue = ew_HtmlEncode($orders_movie->email->CurrentValue);

		// address
		$orders_movie->address->EditCustomAttributes = "";
		$orders_movie->address->EditValue = ew_HtmlEncode($orders_movie->address->CurrentValue);

		// tel
		$orders_movie->tel->EditCustomAttributes = "";
		$orders_movie->tel->EditValue = ew_HtmlEncode($orders_movie->tel->CurrentValue);

		// note
		$orders_movie->note->EditCustomAttributes = "";
		$orders_movie->note->EditValue = ew_HtmlEncode($orders_movie->note->CurrentValue);

		// pro_id
		$orders_movie->pro_id->EditCustomAttributes = "";
		$orders_movie->pro_id->EditValue = ew_HtmlEncode($orders_movie->pro_id->CurrentValue);

		// pro_title
		$orders_movie->pro_title->EditCustomAttributes = "";
		$orders_movie->pro_title->EditValue = ew_HtmlEncode($orders_movie->pro_title->CurrentValue);

		// pro_quantity
		$orders_movie->pro_quantity->EditCustomAttributes = "";
		$orders_movie->pro_quantity->EditValue = ew_HtmlEncode($orders_movie->pro_quantity->CurrentValue);

		// pro_totalmoney
		$orders_movie->pro_totalmoney->EditCustomAttributes = "";
		$orders_movie->pro_totalmoney->EditValue = ew_HtmlEncode($orders_movie->pro_totalmoney->CurrentValue);

		// dateadd
		$orders_movie->dateadd->EditCustomAttributes = "";
		$orders_movie->dateadd->EditValue = ew_HtmlEncode(ew_FormatDateTime($orders_movie->dateadd->CurrentValue, 7));

		// status
		$orders_movie->status->EditCustomAttributes = "";
		$arwrk = array();
		$arwrk[] = array("1", "Active");
		$orders_movie->status->EditValue = $arwrk;
	} elseif ($orders_movie->RowType == EW_ROWTYPE_EDIT) { // Edit row
	} elseif ($orders_movie->RowType == EW_ROWTYPE_SEARCH) { // Search row
	}

	// Call Row Rendered event
	$orders_movie->Row_Rendered();
}
?>
<?php

// Add record
function AddRow() {
	global $conn, $Security, $orders_movie;

	// Check for duplicate key
	$bCheckKey = TRUE;
	$sFilter = $orders_movie->SqlKeyFilter();
	if (trim(strval($orders_movie->id->CurrentValue)) == "") {
		$bCheckKey = FALSE;
	} else {
		$sFilter = str_replace("@id@", ew_AdjustSql($orders_movie->id->CurrentValue), $sFilter); // Replace key value
	}
	if (!is_numeric($orders_movie->id->CurrentValue)) {
		$bCheckKey = FALSE;
	}
	if ($bCheckKey) {
		$rsChk = $orders_movie->LoadRs($sFilter);
		if ($rsChk && !$rsChk->EOF) {
			$_SESSION[EW_SESSION_MESSAGE] = "Duplicate value for primary key";
			$rsChk->Close();
			return FALSE;
		}
	}
	$rsnew = array();

	// Field bill
	$orders_movie->bill->SetDbValueDef($orders_movie->bill->CurrentValue, "");
	$rsnew['bill'] =& $orders_movie->bill->DbValue;

	// Field fullname
	$orders_movie->fullname->SetDbValueDef($orders_movie->fullname->CurrentValue, NULL);
	$rsnew['fullname'] =& $orders_movie->fullname->DbValue;

	// Field email
	$orders_movie->email->SetDbValueDef($orders_movie->email->CurrentValue, NULL);
	$rsnew['email'] =& $orders_movie->email->DbValue;

	// Field address
	$orders_movie->address->SetDbValueDef($orders_movie->address->CurrentValue, NULL);
	$rsnew['address'] =& $orders_movie->address->DbValue;

	// Field tel
	$orders_movie->tel->SetDbValueDef($orders_movie->tel->CurrentValue, NULL);
	$rsnew['tel'] =& $orders_movie->tel->DbValue;

	// Field note
	$orders_movie->note->SetDbValueDef($orders_movie->note->CurrentValue, NULL);
	$rsnew['note'] =& $orders_movie->note->DbValue;

	// Field pro_id
	$orders_movie->pro_id->SetDbValueDef($orders_movie->pro_id->CurrentValue, NULL);
	$rsnew['pro_id'] =& $orders_movie->pro_id->DbValue;

	// Field pro_title
	$orders_movie->pro_title->SetDbValueDef($orders_movie->pro_title->CurrentValue, NULL);
	$rsnew['pro_title'] =& $orders_movie->pro_title->DbValue;

	// Field pro_quantity
	$orders_movie->pro_quantity->SetDbValueDef($orders_movie->pro_quantity->CurrentValue, NULL);
	$rsnew['pro_quantity'] =& $orders_movie->pro_quantity->DbValue;

	// Field pro_totalmoney
	$orders_movie->pro_totalmoney->SetDbValueDef($orders_movie->pro_totalmoney->CurrentValue, NULL);
	$rsnew['pro_totalmoney'] =& $orders_movie->pro_totalmoney->DbValue;

	// Field dateadd
	$orders_movie->dateadd->SetDbValueDef(ew_UnFormatDateTime($orders_movie->dateadd->CurrentValue, 7), ew_CurrentDate());
	$rsnew['dateadd'] =& $orders_movie->dateadd->DbValue;

	// Field status
	$orders_movie->status->SetDbValueDef($orders_movie->status->CurrentValue, 0);
	$rsnew['status'] =& $orders_movie->status->DbValue;

	// Call Row Inserting event
	$bInsertRow = $orders_movie->Row_Inserting($rsnew);
	if ($bInsertRow) {
		$conn->raiseErrorFn = 'ew_ErrorFn';
		$AddRow = $conn->Execute($orders_movie->InsertSQL($rsnew));
		$conn->raiseErrorFn = '';
	} else {
		if ($orders_movie->CancelMessage <> "") {
			$_SESSION[EW_SESSION_MESSAGE] = $orders_movie->CancelMessage;
			$orders_movie->CancelMessage = "";
		} else {
			$_SESSION[EW_SESSION_MESSAGE] = "Insert cancelled";
		}
		$AddRow = FALSE;
	}
	if ($AddRow) {
		$orders_movie->id->setDbValue($conn->Insert_ID());
		$rsnew['id'] =& $orders_movie->id->DbValue;

		// Call Row Inserted event
		$orders_movie->Row_Inserted($rsnew);
	}
	return $AddRow;
}
?>
<?php

// Page Load event
function Page_Load() {

	//echo "Page Load";
}

// Page Unload event
function Page_Unload() {

	//echo "Page Unload";
}
?>
